

package NinetyNine;

import java.io.Serializable;
import java.text.DecimalFormat;
import java.util.ArrayList;

/**
 *
 * @author JOKE
 * Scoreboard
 */
public class ScoreBoard implements Serializable {
    private ArrayList<Score> gamesWon = null;
    private ArrayList<Score> gamesPlayed = null;
    private ArrayList<Score> winRatio = null;

    public ArrayList<Score> getGamesPlayed() {
        return gamesPlayed;
    }

    public void setGamesPlayed(ArrayList<Score> gamesPlayed) {
        this.gamesPlayed = gamesPlayed;
    }

    public ArrayList<Score> getGamesWon() {
        return gamesWon;
    }

    public void setGamesWon(ArrayList<Score> gamesWon) {
        this.gamesWon = gamesWon;
    }

    public ArrayList<Score> getWinRatio() {
        return winRatio;
    }

    public void setWinRatio(ArrayList<Score> winRatio) {
        this.winRatio = winRatio;
    }

    public ScoreBoard() {
        this.gamesWon = new ArrayList<Score>(10);
        this.gamesPlayed = new ArrayList<Score>(10);
        this.winRatio = new ArrayList<Score>(10);
    }

    public ArrayList convertScores() {
        ArrayList convert = new ArrayList();
        DecimalFormat fmt = new DecimalFormat("#.####");
        String[][] won = new String[10][3];
        String[][] played = new String[10][3];
        String[][] ratio = new String[10][3];
        for(int rank=0;rank<10;rank++) {
            played[rank][0] = Integer.toString(rank+1);
            played[rank][1] = this.gamesPlayed.get(rank).getUser();
            played[rank][2] = played[rank][1].equals("") ? "" : 
                Integer.toString((int)this.gamesPlayed.get(rank).getScore());
            won[rank][0] = Integer.toString(rank+1);
            won[rank][1] = this.gamesWon.get(rank).getUser();
            won[rank][2] = won[rank][1].equals("") ? "" : 
                Integer.toString((int)this.gamesWon.get(rank).getScore());
            ratio[rank][0] = Integer.toString(rank+1);
            ratio[rank][1] = this.winRatio.get(rank).getUser();
            ratio[rank][2] = ratio[rank][1].equals("") ? "" : 
                fmt.format(this.winRatio.get(rank).getScore());
        }
        convert.add(played);
        convert.add(won);
        convert.add(ratio);
        return convert;
    }
}
